#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from bs4 import BeautifulSoup
import requests

class BestbuySpider:
  def __init__(self, url):
    self.url = url

  def getData(self):
    headers = {
      'user-agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36'
    }
    req = requests.get(self.url, headers=headers)
    soup = BeautifulSoup(req.text)

    price = soup.find('div', class_='pb-hero-price pb-purchase-price').contents[0].get_text()
    title = soup.find('div', class_="sku-title").contents[0].string

    return {
      'price': price,
      'title': title,
    }

